package com.lanswon.qzsmk.service.cardManageService.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lanswon.qzsmk.base.AccountContants;
import com.lanswon.qzsmk.base.AppContants;
import com.lanswon.qzsmk.base.CardContants;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.dao.AppKindMapper;
import com.lanswon.qzsmk.dao.AppOpenRegMapper;
import com.lanswon.qzsmk.dao.CardControlMapper;
import com.lanswon.qzsmk.dao.CardDataMapper;
import com.lanswon.qzsmk.dao.CardProdunctDefinitionMapper;
import com.lanswon.qzsmk.dao.CertMapper;
import com.lanswon.qzsmk.dao.CertificateMapper;
import com.lanswon.qzsmk.dao.CooperationCompanyMapper;
import com.lanswon.qzsmk.dao.OnlSubaccountPersonalMapper;
import com.lanswon.qzsmk.dao.PaperTypeMapper;
import com.lanswon.qzsmk.dao.PersonalMapper;
import com.lanswon.qzsmk.dao.QueryBatchApplicationMapper;
import com.lanswon.qzsmk.dao.QueryBusinessCountMapper;
import com.lanswon.qzsmk.dao.QueryCardInfoMapper;
import com.lanswon.qzsmk.dao.QueryCertMapper;
import com.lanswon.qzsmk.dao.QueryChangeCardMapper;
import com.lanswon.qzsmk.dao.QueryHandleMapper;
import com.lanswon.qzsmk.dao.QueryLossMapper;
import com.lanswon.qzsmk.dao.QueryMakeCardTaskMapper;
import com.lanswon.qzsmk.dao.SubaccountPersonalMapper;
import com.lanswon.qzsmk.model.AppKind;
import com.lanswon.qzsmk.model.AppOpenReg;
import com.lanswon.qzsmk.model.CardControl;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.model.Cert;
import com.lanswon.qzsmk.model.FeeRules;
import com.lanswon.qzsmk.model.Personal;
import com.lanswon.qzsmk.service.appManageService.AppFeeService;
import com.lanswon.qzsmk.service.cardManageService.QueryCardInfoService;
import com.lanswon.qzsmk.service.systemManageService.ParamManageService;
import com.lanswon.qzsmk.vo.AcountDetailVo;
import com.lanswon.qzsmk.vo.CardDetailedVo;
import com.lanswon.qzsmk.vo.FeeRulesVo;
import com.lanswon.qzsmk.vo.MakeCardQueryConditionVo;
import com.lanswon.qzsmk.vo.PersonalVo;
import com.lanswon.qzsmk.vo.QueryBatchApplicationVo;
import com.lanswon.qzsmk.vo.QueryCardInfoVo;
import com.lanswon.qzsmk.vo.QueryCertVo;
import com.lanswon.qzsmk.vo.QueryChangeCardVo;
import com.lanswon.qzsmk.vo.QueryLossAndUnbindVo;
import com.lanswon.qzsmk.vo.QueryMakeCardTaskVo;

@Service
public class QueryCardInfoServiceImpl implements QueryCardInfoService {

	@Autowired
	QueryCardInfoMapper qcim;
	
	@Autowired
	CardProdunctDefinitionMapper cpdm;
	
	@Autowired
	PaperTypeMapper ptm;
	
	@Autowired
	ParamManageService paramManage;
	
	@Autowired
	PersonalMapper pm;
	
	@Autowired
	CardControlMapper ccm;
	
	@Autowired
	CardDataMapper cdm;
	
	@Autowired
	OnlSubaccountPersonalMapper ospm;
	
	@Autowired
	CertMapper cm;
	
	@Autowired
	QueryBatchApplicationMapper qbam;
	
	@Autowired
	QueryMakeCardTaskMapper qmm;
	
	@Autowired
	CooperationCompanyMapper companMapper;
	
	@Autowired
	CertificateMapper cfm;
	
	@Autowired
	QueryLossMapper qlm;
	
	@Autowired
	QueryChangeCardMapper qcm;
	
	@Autowired
	QueryBusinessCountMapper qbcm;
	
	@Autowired 
	QueryCertMapper qcertM;
	
	@Autowired
	QueryHandleMapper qhm;
	
	@Autowired
	AppFeeService afs;
	
	@Autowired
	SubaccountPersonalMapper spm;
	
	@Autowired
	AppOpenRegMapper apm;
	
	@Autowired
	AppKindMapper akm;
	/**
	 * 查询卡信息
	 * @param qci
	 * @return
	 */
	@Override
	public DwzPage<QueryCardInfoVo> queryCardInfo(QueryCardInfoVo qci) {
		List<QueryCardInfoVo> list=qcim.queryCardInfo(qci);
		List<QueryCardInfoVo> lists=new ArrayList<>();
		for(QueryCardInfoVo qInfoVo:list){
//			qInfoVo.setCardPName(cpdm.queryCardPCode(qInfoVo.getCardPCode()).getCardpName());
//			if(qInfoVo.getPaperType()!=null){
//				qInfoVo.setPaperTypeName(ptm.queryPaperTypeByCode(qInfoVo.getPaperType()).getCertificatesName());
//			}
			qInfoVo.setCardStauts(CardContants.getCardStatusNameByCode(qInfoVo.getCardStautsCode()));
			qInfoVo.setCardPosition(CardContants.getCardPositionNameByCode(qInfoVo.getCardPosition()));
			if(qInfoVo.getCardPCode().equals(CardContants.CARD_P_CODE_JS)){
				qInfoVo.setCollBranchNameSingle("建设银行");
			}
			if(qInfoVo.getCardPCode().equals(CardContants.CARD_P_CODE_WF)){
				qInfoVo.setCollBranchNameSingle("潍坊银行");
			}
			lists.add(qInfoVo);
		}
		int totalCount=qcim.queryCardInfoCount(qci);
		DwzPage<QueryCardInfoVo> dPage=new DwzPage<QueryCardInfoVo>(qci.getCurrentPage(), qci.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	/**
	 * 获取卡详细信息
	 * @param paperType
	 * @param paperNo
	 * @param citizenCardNo
	 * @return
	 * @throws Exception
	 */
	@Override
	public Map<String, Object> getDetailedInfo(String paperType, String paperNo, String citizenCardNo) throws Exception {
		Map<String,Object> map=new HashMap<>();
		//个人信息
		Personal personal=pm.queryPersonalByPaperNo(paperType,paperNo);
		personal.setPaperType(paramManage.queryPaperByPaperTypeCode(paperType).getCertificatesName());
		
		CardDetailedVo  cardDetailedVo=qcim.queryDetailByCitizenCardNo(citizenCardNo);
		cardDetailedVo.setCardPositionName(CardContants.getCardPositionNameByCode(cardDetailedVo.getCardPosition()));
		cardDetailedVo.setCardStatusName(CardContants.getCardStatusNameByCode(cardDetailedVo.getCardStatus()));
		if(cardDetailedVo.getApplyBatchNo()==null){//单笔申请
			Cert cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.SINGLE_APPLICATION);
			if(cert==null){
				cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.CARD_ISSUING_APPLY);
			}
			if(cert==null){
				cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.CARD_CHANGE_APPLY);
			}
			cardDetailedVo.setApplyDate(cert.getCrtDate());
			cardDetailedVo.setApplyNet(cert.getBranch());
			if(!cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_DISABLED)){//单笔发卡
				cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.SINGLE_CARD);
				if(cert==null){
					cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.CARD_ISSUING_CARD);
				}
				cardDetailedVo.setReissueDate(cert.getCrtDate());
				cardDetailedVo.setReissueNet(cert.getBranch());
			}
		}else{//批量申请
			Cert cert=qcim.queryCertByBatchApplyNoAndCertType(cardDetailedVo.getApplyBatchNo(), CardContants.BATCH_APPLICATION);
			cardDetailedVo.setApplyDate(cert.getCrtDate());
			cardDetailedVo.setApplyNet(cert.getBranch());
			if(!cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_DISABLED)){//批量发卡
				cert=qcim.queryCertByBatchApplyNoAndCertType(cardDetailedVo.getApplyBatchNo(), CardContants.BATCH_CARD);
				cardDetailedVo.setReissueDate(cert.getCrtDate());
				cardDetailedVo.setReissueNet(cert.getBranch());
			}
		}
		//银行联名卡注销
		if(cardDetailedVo.getCardPCode().equals(CardContants.CARD_P_CODE_JS)||cardDetailedVo.getCardPCode().equals(CardContants.CARD_P_CODE_WF)){
			if(cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_CANCELLATION_NO_CARD)||cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_CANCELLATION_HAS_CARD)){
				Cert cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.BACK_CARD_REGISTRATION);
				cardDetailedVo.setCancelDate(cert.getCrtDate());
			}
		}else{//普通市民卡注销//
			if(cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_CANCELLATION_NO_CARD)){
				Cert cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(),CardContants.SPOT_REFUND);//现场退卡退款
				if(cert==null){
					cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.BACK_CARD_REGISTRATION);//退卡登记
				}
				cardDetailedVo.setCancelDate(cert.getCrtDate());
			}else if(cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_CANCELLATION_HAS_CARD)){
				Cert cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(),CardContants.SPOT_REFUND);
				if(cert==null){
					cert=qcim.queryCertByControlIdAndCertType(cardDetailedVo.getControlId(), CardContants.BACK_CARD_REGISTRATION);
				}
				cardDetailedVo.setCancelDate(cert.getCrtDate());
			}
		}
		
		
		//费用
		FeeRules feeRules=null;
		if(cardDetailedVo.getCardPCode().equals(CardContants.CARD_P_CODE_JS)||cardDetailedVo.getCardPCode().equals(CardContants.CARD_P_CODE_WF)){
			if(!cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_DISABLED)){
				FeeRulesVo vo=new FeeRulesVo();
				vo.setCardpCode(cardDetailedVo.getCardPCode());
				vo.setFeeType(AccountContants.FEE_TYPE_NOMINAL_FEE);//工本费代码
				feeRules=afs.queryFeeRulesByCardPCodeAndFeeType(vo);
			}
		}
		
		//应用开通
		
		List<AcountDetailVo> list=null;
		if(!cardDetailedVo.getCardStatus().equals(CardContants.CARD_STATE_DISABLED)){
			list=qcim.queryAcountDatailByCitizenCardNo(citizenCardNo, AccountContants.FEE_TYPE_DEPOSIT,cardDetailedVo.getCardPCode());
		}
		
		System.out.println(personal+"\n"+cardDetailedVo+"\n"+feeRules+"\n"+list);
		map.put("personal", personal);
		map.put("cardDetailedVo",cardDetailedVo);
		map.put("list",list);
		map.put("FeeRules",feeRules);
		//map.put("", );
		return map;
	}
	
	/**
	 * 查询申领信息
	 */
	@Override
	public DwzPage<QueryCardInfoVo> queryApplication(QueryCardInfoVo qci) {
		qci.setCertType(CardContants.SINGLE_APPLICATION);
//		qci.setCertType2(CardContants.CARD_ISSUING_APPLY);
//		qci.setCertType3(CardContants.CARD_CHANGE_APPLY);
		List<QueryCardInfoVo> list=qcim.queryApplication(qci);
		List<QueryCardInfoVo> lists=new ArrayList<>();
		for(QueryCardInfoVo qInfoVo:list){
//			qInfoVo.setCardPName(cpdm.queryCardPCode(qInfoVo.getCardPCode()).getCardpName());
//			qInfoVo.setPaperTypeName(ptm.queryPaperTypeByCode(qInfoVo.getPaperType()).getCertificatesName());
			qInfoVo.setCardStauts(CardContants.getCardStatusNameByCode(qInfoVo.getCardStautsCode()));
			qInfoVo.setCardPosition(CardContants.getCardPositionNameByCode(qInfoVo.getCardPosition()));
			qInfoVo.setClaimStatus(CardContants.getClaimStatusNameByCode(qInfoVo.getClaimStatus()));
			if(qInfoVo.getCitizenCardNo()!=null){
				Cert cert=cm.queryCertByCitizenCardNoAndCertType(qInfoVo.getCitizenCardNo(),CardContants.SINGLE_CARD);
					if(cert!=null){
						qInfoVo.setReleaseCollBranch(cert.getBranch());
						if(cert.getAgentName()!=null){
							qInfoVo.setCardPeople(cert.getAgentName());
						}else{
							qInfoVo.setCardPeople(cert.getName());
						}
						qInfoVo.setReleaseOperator(cert.getCrtOperator());
					}
					
			}
			lists.add(qInfoVo);
		}
		int totalCount=qcim.queryApplicationCount(qci);
		DwzPage<QueryCardInfoVo> dPage=new DwzPage<QueryCardInfoVo>(qci.getCurrentPage(), qci.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	
	/**
	 * 批量申领查询
	 */
	@Override
	public DwzPage<QueryBatchApplicationVo> queryApplicationBatch(QueryBatchApplicationVo qbv) {
		List<QueryBatchApplicationVo> list=qbam.queryApplicationBatch(qbv);
		List<QueryBatchApplicationVo> lists=new ArrayList<>();
		for(QueryBatchApplicationVo qbav:list){
//			qbav.setCardPName(cpdm.queryCardPCode(qbav.getCardPCode()).getCardpName());
			if(qbav.getTaskStatus()!=null){
				qbav.setTaskStatus(CardContants.getTaskStatusNameByCode(qbav.getTaskStatus()));
			}else{
				qbav.setTaskStatus("任务未生成");
			}
			Cert cert=qbam.QueryBathSellCardCert(qbav.getApplyBatchNo(),CardContants.BATCH_CARD);
			if(cert!=null){
				qbav.setReleaseOperator(cert.getCrtOperator());
				qbav.setReleaseDate(cert.getCrtDate());
//				System.out.println(cert);
//				System.out.println(cert.getCrtOperator()+"!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
			}
			lists.add(qbav);
		}
		int totalCount=qbam.queryApplicationBatchCount(qbv);
		DwzPage<QueryBatchApplicationVo> dPage=new DwzPage<>(qbv.getCurrentPage(), qbv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	
	/**
	 * 任务查询
	 */
	@Override
	public DwzPage<QueryMakeCardTaskVo> queryMakeCard(QueryMakeCardTaskVo qmtv) {
		List<QueryMakeCardTaskVo> list=qmm.queryMakeCard(qmtv);
		List<QueryMakeCardTaskVo> lists=new ArrayList<>();
		for(QueryMakeCardTaskVo qmv:list){
//			qmv.setTaskType(CardContants.getTaskTypeNameByCode(qmv.getTaskType()));
//			System.out.println(qmv.getTaskStatus()+"======制卡任务啊");
			if(qmv.getTaskStatus().equals(CardContants.ALREADY_MADE_CARD)){
				Cert cert=qbam.QueryBathSellCardCert(qmv.getApplyBatchNo(),CardContants.BATCH_CARD);
				if(cert!=null){
					qmv.setCardPCode(cert.getCrtOperator());
					qmv.setReleaseDate(cert.getCrtDate());
					}
			}
			qmv.setTaskStatus(CardContants.getTaskStatusNameByCode(qmv.getTaskStatus()));
			lists.add(qmv);
			}
		int totalCount=qmm.queryMakeCardCount(qmtv);
		DwzPage<QueryMakeCardTaskVo> dPage=new DwzPage<>(qmtv.getCurrentPage(), qmtv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
		
		}
	/**
	 * 通过任务编号获取详细信息
	 */
	@Override
	public DwzPage<PersonalVo> queryInfoByCardTaskNo(MakeCardQueryConditionVo mcv) {
		List<PersonalVo> list = qmm.queryInfoByCardTaskNo(mcv);
		List<PersonalVo> l = new ArrayList<>();
		for (PersonalVo pv : list) {
			pv.setPaperType(cfm.queryCertificateByCode(pv.getPaperType()).getCertificatesName());
			pv.setCardPosition(CardContants.getCardPositionNameByCode(pv.getCardPosition()));
			l.add(pv);
		}

		int totalCount = qmm.queryInfoCountByCardTaskNo(mcv);
		DwzPage<PersonalVo> dp = new DwzPage<PersonalVo>(mcv.getCurrentPage(),
				mcv.getNumPerPage(), totalCount);
		dp.setList(l);
		return dp;
		
	}
	/**
	 * 挂失查询
	 */
	@Override
	public DwzPage<QueryLossAndUnbindVo> queryLossAndUnbind(QueryLossAndUnbindVo qlv) {
		qlv.setCertType1(CardContants.OFFICIAL_LOSS);
		qlv.setCertType2(CardContants.ORAL_LOSS);
		qlv.setCertType3(CardContants.CARD_UNBIND);
		List<QueryLossAndUnbindVo> list=qlm.queryLossAndUnbind(qlv);
		List<QueryLossAndUnbindVo> lists=new ArrayList<>();
		for(QueryLossAndUnbindVo qlvo:list){
			qlvo.setCertType(CardContants.getCertTypeNameByCode(qlvo.getCertType()));
			lists.add(qlvo);
		}
		int totalCount=qlm.queryLossAndUnbindCount(qlv);
		DwzPage<QueryLossAndUnbindVo> dPage=new DwzPage<>(qlv.getCurrentPage(), qlv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	
	/**
	 * 换卡补卡查询
	 */
	@Override
	public DwzPage<QueryChangeCardVo> queryChangeAndSupplement(QueryChangeCardVo qcv) {
		qcv.setCertType1(CardContants.CARD_ISSUING_APPLY);
		qcv.setCertType2(CardContants.CARD_CHANGE_APPLY);
		List<QueryChangeCardVo> list=qcm.queryChangeAndSupplement(qcv);
		List<QueryChangeCardVo> lists=new ArrayList<>();
		for(QueryChangeCardVo qccv:list){
			qccv.setCertType(CardContants.getCertTypeNameByCode(qccv.getCertType()));
			qccv.setCertType1(CardContants.CARD_ISSUING_CARD);
			if (qccv.getChcOriCitizenNo()!=null) {
				CardData cd=cdm.queryCardDataByOldCitizenCardNo(qccv.getChcOriCitizenNo());
				if(cd!=null){
					qccv.setCitizenCardNo(cd.getCitizenCardNo());
				}
				CardControl cardControl=ccm.queryCardControlByCardDataId(cd.getCardDataId());
				qccv.setCardControlId(cardControl.getCardControlId());
				Cert cert=cm.queryCertByControlIdAndCertType(qccv);
				if(cert!=null){
					qccv.setReleaseDate(cert.getCrtDate());
				}				
			}
			lists.add(qccv);
		}
		int totalCount=qcm.queryChangeAndSupplementCount(qcv);
		DwzPage<QueryChangeCardVo> dPage=new DwzPage<>(qcv.getCurrentPage(), qcv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
		
	}
	
	/**
	 * 业务统计查询
	 */
	@Override
	public DwzPage<QueryChangeCardVo> queryBusinessCount(QueryChangeCardVo qcv) {
		List<QueryChangeCardVo> list=qbcm.queryBusinessCount(qcv);
		List<QueryChangeCardVo> lists=new ArrayList<>();
		for(QueryChangeCardVo qccv:list){
			qccv.setCertType(CardContants.getCertTypeNameByCode(qccv.getCertType()));
//			qccv.setCardPName(cpdm.queryCardPCode(qccv.getCardPCode()).getCardpName());
			lists.add(qccv);
		}
		int totalCount=qbcm.queryCountBusiness(qcv);
		DwzPage<QueryChangeCardVo> dPage=new DwzPage<>(qcv.getCurrentPage(), qcv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	@Override
	public DwzPage<QueryCertVo> queryCert(QueryCertVo qcv) {
		qcv.setCert_type1(CardContants.SINGLE_APPLICATION);
		qcv.setCert_type4(CardContants.BATCH_APPLICATION);
		qcv.setCert_type6(CardContants.OFFICIAL_LOSS);
		qcv.setCert_type2(CardContants.ORAL_LOSS);
		qcv.setCert_type5(CardContants.CARD_ISSUING_APPLY);
		qcv.setCert_type7(CardContants.CARD_CHANGE_APPLY);
		qcv.setCert_type3(CardContants.BACK_CARD_REGISTRATION);
		List<QueryCertVo> list=qcertM.queryCert(qcv);
		List<QueryCertVo> lists=new ArrayList<>();
		for(QueryCertVo qcev:list){
			if(qcev.getTransCode()!=null){
				qcev.setTransName(qcev.getTransCode());//这需要改以后
			}
			qcev.setCertType(CardContants.getCertTypeNameByCode(qcev.getCertType()));
//			qcev.setCardpName(cpdm.queryCardPCode(qcev.getCardpCode()).getCardpName());
			lists.add(qcev);
		}
		int totalCount=qcertM.queryCertCount(qcv);
		DwzPage<QueryCertVo> dPage=new DwzPage<>(qcv.getCurrentPage(), qcv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	/**
	 * 办理情况查询
	 * @param qcv
	 * @return
	 */
	@Override
	public DwzPage<QueryCertVo> queryHandleInfo(QueryCertVo qcv) {
		List<QueryCertVo> list=qhm.queryHandleInfo(qcv);
		List<QueryCertVo> lists=new ArrayList<>();
		for(QueryCertVo qcev:list){
			qcev.setCertType(CardContants.getCertTypeNameByCode(qcev.getCertType()));
//			qcev.setCardpName(cpdm.queryCardPCode(qcev.getCardpCode()).getCardpName());
			if(qcev.getTransCode()!=null){
				qcev.setTransName(qcev.getTransCode());//这需要改以后
			}
			if(qcev.getClaimStatus()!=null){
				qcev.setClaimStatus(CardContants.getClaimStatusNameByCode(qcev.getClaimStatus()));
			}
			
			lists.add(qcev);
		}
		int totalCount=qhm.queryHandleInfoCount(qcv);
		DwzPage<QueryCertVo> dPage=new DwzPage<>(qcv.getCurrentPage(), qcv.getNumPerPage(), totalCount);
		dPage.setList(lists);
		return dPage;
	}
	
	@Override	
	public Map<String,Object> queryinfoByCitizenCardNo(String citizenCardNo){
		Map<String, Object> map=new HashMap<>();
		QueryCardInfoVo qVo=null;
		qVo=qcim.queryinfoByCitizenCardNo(citizenCardNo);
		if(qVo.getCardStautsCode().equals(CardContants.CARD_STATE_NORMAL)){
			List<AppOpenReg> appOpenRegs=apm.queryAppOpenRegByCitizenCardNo(citizenCardNo, AppContants.APP_STATUS_OPEN);
			List<AppKind> kinds=new ArrayList<>();
			Iterator<AppOpenReg > iterator=appOpenRegs.iterator();
			while(iterator.hasNext()){
				AppOpenReg appOpenReg=iterator.next();
				AppKind appKind=akm.queryAppKindByTypeCode(Integer.valueOf(appOpenReg.getAppType()));
				kinds.add(appKind);
			}
			if(kinds.size()>0){
				map.put("statusCode", 200);
				map.put("appKinds", kinds);
			}else{
				map.put("statusCode", 300);
				map.put("message", "此卡为开通任何应用");
			}
		}else{
			map.put("statusCode", 300);
			map.put("message", "此卡状态为"+CardContants.getCardStatusNameByCode(qVo.getCardStautsCode()));
		}
		
		map.put("qVo", qVo);
		
		return map;
	}
	
	

}
